package xin.clips.system.service.impl;

import java.util.List;
import xin.clips.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import xin.clips.common.core.text.Convert;
import xin.clips.system.domain.gy.GyInnerMessage;
import xin.clips.system.mapper.gy.GyInnerMessageMapper;
import xin.clips.system.service.gy.IGyInnerMessageService;

/**
 * 站内信Service业务层处理
 *
 * @author clips
 * @date 2023-03-10
 */
@Service
public class GyInnerMessageServiceImpl implements IGyInnerMessageService
{
    @Autowired
    private GyInnerMessageMapper gyInnerMessageMapper;

    /**
     * 查询站内信
     *
     * @param messageId 站内信主键
     * @return 站内信
     */
    @Override
    public GyInnerMessage selectGyInnerMessageByMessageId(Long messageId)
    {
        return gyInnerMessageMapper.selectGyInnerMessageByMessageId(messageId);
    }

    /**
     * 查询站内信列表
     *
     * @param gyInnerMessage 站内信
     * @return 站内信
     */
    @Override
    public List<GyInnerMessage> selectGyInnerMessageList(GyInnerMessage gyInnerMessage)
    {
        return gyInnerMessageMapper.selectGyInnerMessageList(gyInnerMessage);
    }

    /**
     * 新增站内信
     *
     * @param gyInnerMessage 站内信
     * @return 结果
     */
    @Override
    public int insertGyInnerMessage(GyInnerMessage gyInnerMessage)
    {
        gyInnerMessage.setCreateTime(DateUtils.getNowDate());
        return gyInnerMessageMapper.insertGyInnerMessage(gyInnerMessage);
    }

    /**
     * 修改站内信
     *
     * @param gyInnerMessage 站内信
     * @return 结果
     */
    @Override
    public int updateGyInnerMessage(GyInnerMessage gyInnerMessage)
    {
        gyInnerMessage.setUpdateTime(DateUtils.getNowDate());
        return gyInnerMessageMapper.updateGyInnerMessage(gyInnerMessage);
    }

    /**
     * 批量删除站内信
     *
     * @param messageIds 需要删除的站内信主键
     * @return 结果
     */
    @Override
    public int deleteGyInnerMessageByMessageIds(String messageIds)
    {
        return gyInnerMessageMapper.deleteGyInnerMessageByMessageIds(Convert.toStrArray(messageIds));
    }

    /**
     * 删除站内信信息
     *
     * @param messageId 站内信主键
     * @return 结果
     */
    @Override
    public int deleteGyInnerMessageByMessageId(Long messageId)
    {
        return gyInnerMessageMapper.deleteGyInnerMessageByMessageId(messageId);
    }


    /**
     * 查询未读站内信数量
     *
     * @param gyInnerMessage 站内信
     * @return 站内信集合
     */
    public Integer  selectUnreadInnerMessageTotalByUserId(GyInnerMessage gyInnerMessage){
        return gyInnerMessageMapper.selectUnreadInnerMessageTotalByUserId(gyInnerMessage);
    }

    /**
     * 查询站内信列表
     *
     * @param gyInnerMessage 站内信
     * @return 站内信集合
     */
    public List<GyInnerMessage> selectGyInnerMessageListLimt(GyInnerMessage gyInnerMessage){
        return gyInnerMessageMapper.selectGyInnerMessageListLimt(gyInnerMessage);
    }
}
